home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
RLaB 1.18c
/
testmatrix
/
chebvand.r
< prev
next >
Wrap
Text File
|
1994-12-20
|
2KB
|
65 lines
//-------------------------------------------------------------------//
// Synopsis: Vandermonde-like matrix for the Chebyshev polynomials.
// Syntax: C = chebvand ( P )
// C = chebvand ( M , P )
// Description:
// C = chebvand(P), where P is a vector, produces the (primal)
// Chebyshev Vandermonde matrix based on the points P, i.e.,
// C(i,j) = T_{i-1}(P(j)), where T_{i-1} is the Chebyshev
// polynomial of degree i-1.
// chebvand(M,P) is a rectangular version of chebvand(P) with M
// rows. Special case: If P is a scalar then P equally spaced
// points on [0,1] are used.
// Reference:
// N.J. Higham, Stability analysis of algorithms for solving confluent
// Vandermonde-like systems, SIAM J. Matrix Anal. Appl., 11 (1990),
// pp. 23-41.
// This file is a translation of chebvand.m from version 2.0 of
// "The Test Matrix Toolbox for Matlab", described in Numerical
// Analysis Report No. 237, December 1993, by N. J. Higham.
// Dependencies
rfile seqa
//-------------------------------------------------------------------//
chebvand = function ( m , p )
{
local (m, p)
if (!exist (p))
{
p = m;
}
n = max(size(p));
// Handle scalar p.
if (n == 1)
{
n = p;
p = seqa(0,1,n);
}
if (!exist (_p)) { m = n; }
p = p[:].'; // Ensure p is a row vector.
C = ones(m,n);
if (m == 1) { return C; }
C[2;] = p;
// Use Chebyshev polynomial recurrence.
for (i in 3:m)
{
C[i;] = 2.*p.*C[i-1;] - C[i-2;];
}
return C;
};